/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */

package com.bayu.controller;

import com.bayu.services.dao.ExchangeCurrencyImpl;
import com.bayu.services.entity.ExchangeCurrency;
import java.util.Date;
import java.util.List;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.ui.ModelMap;
import org.springframework.web.bind.annotation.RequestMapping;

/**
 *
 * @author Bayu
 */
@Controller
public class TestController {
    private ExchangeCurrencyImpl exchageCurrencyDao;
    @Autowired
    public void setExchageCurrencyDao(ExchangeCurrencyImpl exchageCurrencyDao){
        this.exchageCurrencyDao = exchageCurrencyDao;
    }
    @RequestMapping("/test.htm")
    public void Test(ModelMap map,String strbulan){
        List list;
        if(!strbulan.isEmpty()){
            list = this.exchageCurrencyDao.getAllByMonth(strbulan);
        }else{
            list = this.exchageCurrencyDao.getAll();
        }


        map.addAttribute("data", list);
    }

    @RequestMapping("/test2.htm")
    public void Test2(ModelMap map,String strbulan){
        List list;
        if(!strbulan.isEmpty()){
            list = this.exchageCurrencyDao.getAllByMonth(strbulan);
        }else{
            list = this.exchageCurrencyDao.getAll();
        }

        ExchangeCurrency data = (ExchangeCurrency) list.get(0);
        String test = data.getDate().toString();
        map.addAttribute("data",Integer.toString(data.getDate().getDay()));
        map.addAttribute("data2", data.getDate().getDay());
        map.addAttribute("tanggal",test);
        
    }
    


}
